/**
 * Created by aa on 2016/5/17.
 */
function DataOperation(){
    this.userId=wxUtils.getParamsByUrl('userid');
    this.getScore=function(callback){
        var user={userId:parseInt(this.userId)};
        commonAjax(UrlInformation.apipath+'/app/userPointsCtr/getUserPointsByUserId',JSON.stringify(user),function(data){
           var result=JSON.parse(data);
            callback(result.result.leftPoints);
        });
      //  return 9;
    };
    this.getActivityInfo=function(){
        return {
            start:'2016/06/15',
            end:'2016/07/31',
            date:'2016/06/15-2016/07/31'
        }
    };
    //减积分操作，1为1%加息劵，2为0.5%加息劵
    this.reducePoints=function(type,callBack,errorCallBack){
        var point={userId:this.userId,cardId:type};
        commonAjax(UrlInformation.apipath+'/app/userCardCtr/getCard',JSON.stringify(point),function(data){
            var result=JSON.parse(data);
            if(result.result.checkResult) {
                callBack(result.result.leftPoints);
            }
            else{
                errorCallBack(getDescByCode.getCardErrorCode(result.result.checkResultCode));
            }
        });
        /*return 5;*/
    };
    //获取邀请人数前五名
    this.getUsers=function(callback){
        var params={curPage:1,pageSize:5,sortType:3};
        commonAjax(UrlInformation.apipath+'/app/userPointsCtr/getListBySortInfo',JSON.stringify(params),function(data){
            var result=JSON.parse(data);
            callback(result.result);
        });

       // return '{"users":[{"phone":"15326963325","count":18},{"phone":"15326763325","count":17},{"phone":"15326663325","count":16},{"phone":"15326963395","count":15},{"phone":"15326963335","count":14}]}';
    };

}

